//
//  ZBMoBanEightViewController.m
//  MoBan
//
//  Created by apple on 16/7/14.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ZBMoBanEightViewController.h"
#import "ZBMoBanEightCollectionViewCell.h"
#import "ZBMoBanEightHeadView.h"
@interface ZBMoBanEightViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,ZBMoBanEightHeadViewDeleget>
@property(nonatomic,strong)UICollectionView *collectionview;
@property(nonatomic,strong)ZBMoBanEightHeadView *zbheadview;
@end

@implementation ZBMoBanEightViewController
-(ZBMoBanEightHeadView *)zbheadview
{
    if (!_zbheadview) {
        _zbheadview = [[ZBMoBanEightHeadView alloc]init];
        _zbheadview.frame = CGRectMake(0, 0, KscrW, 250*Kscr);
    }
    return _zbheadview;

}
-(UICollectionView *)collectionview
{
    if (!_collectionview) {
        
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
        layout.scrollDirection = UICollectionViewScrollDirectionVertical;
        layout.itemSize = CGSizeMake(KscrW/3, 100*Kscr);
        layout.minimumInteritemSpacing = 0;
        layout.minimumLineSpacing = 0;
        _collectionview = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, KscrW, KscrH-KBar1) collectionViewLayout:layout];
        _collectionview.backgroundColor = [UIColor whiteColor];
        _collectionview.dataSource = self;
        _collectionview.delegate = self;
        [_collectionview registerClass:[ZBMoBanEightCollectionViewCell class] forCellWithReuseIdentifier:@"ZBMoBanEightCollectionViewCell"];
        [_collectionview registerClass:[ZBMoBanEightHeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"ZBMoBanEightHeadView"];
    }
    return _collectionview;


}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.collectionview];
    // Do any additional setup after loading the view.
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{

    return 10;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    ZBMoBanEightCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ZBMoBanEightCollectionViewCell" forIndexPath:indexPath];
    return cell;

}
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
//    if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
    
    
    ZBMoBanEightHeadView *view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"ZBMoBanEightHeadView" forIndexPath:indexPath];
    view.deleget = self;
    [view ZBSetDatasouce:@"hah"];
    
    return view;
        
//    }

}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
    return CGSizeMake(KscrW, 250*Kscr);

}
-(void)ZBDidSelectedAtIndex:(NSInteger)index
{
    [ZBProssHud showsuccessFrom:self.view with:[NSString stringWithFormat:@"%ld",index]];
}
-(void)ZBBtnClic:(UIButton *)butten
{
    if ([butten.titleLabel.text isEqualToString:@"点击登录"]) {
        [ZBProssHud showsuccessFrom:self.view with:@"登陆成功"];
    }else
    {
        [ZBProssHud showsuccessFrom:self.view with:@"设置成功"];
    }
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    [ZBProssHud showsuccessFrom:self.view with:[NSString stringWithFormat:@"点击%ld",indexPath.item]];
}
@end
